from celery import Celery
# 加载django环境
import os
import django
# 导入django环境
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "FSJY.settings.settings")

django.setup()

broker_url='redis://127.0.0.1:6379/3'  #broker任务队列
backend_url='redis://127.0.0.1:6379/4'   # 结构存储，执行完的结果存在这
# worker_max_tasks_per_child = 10
app=Celery(__name__, broker_url=broker_url, backend=backend_url, worker_max_tasks_per_child=10)
app.autodiscover_tasks(['celery_task.tasks.tasks'])  # 指定要自动发现的包名
# 添加定时任务配置
app.conf.beat_schedule = {
    'check-unpaid-orders': {
        'task':'celery_task.tasks.tasks.celery_check_order',
        'schedule': 60.0,  # 每60秒执行一次
    },
}
